package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;

class zaml {
   private zafg a;
   private ArrayList b = new ArrayList();
   private static final com.aspose.cells.b.c.a.za c = new com.aspose.cells.b.c.a.za(new String[]{"7bit", "8bit", "binary", "quoted-printable", "base64", "x-encodingname"});

   public zaml(com.aspose.cells.b.a.d.zm var1, Encoding var2) throws Exception {
      this.a = new zafg(var1, var2);
   }

   public zafg a(String var1) throws Exception {
      try {
         this.a.a("MIME-Version: 1.0");
         this.a.b("X-Document-Type: Workbook");
         this.a.b("Content-Type: multipart/related; boundary=\"" + var1 + "\"");
         this.a.g();
         this.a.b("This document is a Single File Web Page, also known as a Web Archive file.  If you are seeing this message, your browser or editor doesn't support Web Archive files.  Please download a browser that supports Web Archive, such as Windows Internet Explorer.");
         this.a.g();
         this.a.h();
      } finally {
         ;
      }

      return this.a;
   }

   public zafg a(String var1, boolean var2) throws Exception {
      try {
         this.a.g();
         this.a.b(var1 + "--");
         this.a.h();
      } finally {
         if (this.a != null && var2) {
            this.a.f();
         }

      }

      return this.a;
   }

   public void a(com.aspose.cells.b.a.d.zm var1, com.aspose.cells.b.a.d.zm var2, Encoding var3, String var4) throws Exception {
      com.aspose.cells.b.a.d.zo var5 = null;
      String var6 = "Content-Location";
      String var7 = "Content-Transfer-Encoding";
      String var8 = "Content-Type";

      try {
         ArrayList var9 = this.a(var2, var3);
         var5 = new com.aspose.cells.b.a.d.zo(var1, var3);
         var5.c("MIME-Version: 1.0");
         var5.c("X-Document-Type: Workbook");
         var5.c("Content-Type: multipart/related; boundary=\"" + var4.substring(2) + "\"");
         var5.f();
         var5.c("This document is a Single File Web Page, also known as a Web Archive file.  If you are seeing this message, your browser or editor doesn't support Web Archive files.  Please download a browser that supports Web Archive, such as Windows Internet Explorer.");
         var5.f();
         var5.c();
         com.aspose.cells.b.a.d.zh var10 = null;

         for(int var11 = 0; var11 < var9.size(); ++var11) {
            HashMap var12 = (HashMap)var9.get(var11);
            var5.c(var4);
            var5.c(var6 + ":" + var12.get(var6));
            var5.c(var7 + ":" + var12.get(var7));
            var5.c(var8 + ":" + var12.get(var8));
            var5.f();
            var5.c();
            ++var11;
            var10 = (com.aspose.cells.b.a.d.zh)var9.get(var11);
            var5.d().b(var10.m(), 0, (int)var10.h());
            var5.c();
            var10.a();
         }

         var5.c(var4 + "--");
         var5.c();
         var1.b(0L);
      } catch (Exception var13) {
         ;
      }

   }

   public void a(String var1, com.aspose.cells.b.a.d.zm var2, Encoding var3, String var4) throws Exception {
      com.aspose.cells.b.a.d.zo var5 = null;
      String var6 = "Content-Location";
      String var7 = "Content-Transfer-Encoding";
      String var8 = "Content-Type";

      try {
         ArrayList var9 = this.a(var2, var3);
         com.aspose.cells.b.a.d.zc.b(com.aspose.cells.b.a.d.zk.e(var1));
         com.aspose.cells.b.a.d.ze var10 = new com.aspose.cells.b.a.d.ze(var1, 2);
         var5 = new com.aspose.cells.b.a.d.zo(var10, var3);
         var5.c("MIME-Version: 1.0");
         var5.c("X-Document-Type: Workbook");
         var5.c("Content-Type: multipart/related; boundary=\"" + var4.substring(2) + "\"");
         var5.f();
         var5.c("This document is a Single File Web Page, also known as a Web Archive file.  If you are seeing this message, your browser or editor doesn't support Web Archive files.  Please download a browser that supports Web Archive, such as Windows Internet Explorer.");
         var5.f();
         var5.c();
         com.aspose.cells.b.a.d.zh var11 = null;

         for(int var12 = 0; var12 < var9.size(); ++var12) {
            HashMap var13 = (HashMap)var9.get(var12);
            var5.c(var4);
            var5.c(var6 + ":" + var13.get(var6));
            var5.c(var7 + ":" + var13.get(var7));
            var5.c(var8 + ":" + var13.get(var8));
            var5.f();
            var5.c();
            ++var12;
            var11 = (com.aspose.cells.b.a.d.zh)var9.get(var12);
            var5.d().b(var11.m(), 0, (int)var11.h());
            var5.c();
            var11.a();
         }

         var5.c(var4 + "--");
         var5.c();
      } finally {
         if (var5 != null) {
            var5.b();
         }

      }
   }

   private ArrayList a(com.aspose.cells.b.a.d.zm var1, Encoding var2) throws Exception {
      com.aspose.cells.b.a.d.zn var3 = new com.aspose.cells.b.a.d.zn(var1, var2);
      String var5 = "Content-Location";
      String var6 = "Content-Transfer-Encoding";
      String var7 = "Content-Type";
      String var8 = "boundary=";
      int var9 = 0;
      String var10 = null;
      boolean var11 = false;
      com.aspose.cells.b.a.d.zh var12 = null;
      com.aspose.cells.b.a.d.zo var13 = null;
      boolean var14 = false;
      String var15 = null;
      String var16 = null;
      String var17 = null;
      HashMap var18 = null;

      try {
         String var4;
         try {
            while((var4 = var3.f()) != null) {
               if (var9 == 2) {
                  if (var4.indexOf(var8) > -1) {
                     var10 = var4.substring(var4.indexOf(var8) + var8.length());
                     if (var10.startsWith("\"") && var10.startsWith("\"")) {
                        var10 = var10.substring(1, 1 + (var10.length() - 2));
                     }
                  } else {
                     var11 = true;
                     var14 = true;
                  }
               }

               if (zamm.a(var4, var10)) {
                  var11 = true;
               }

               if (var11) {
                  int var19 = 0;
                  String var20 = var4;
                  var12 = new com.aspose.cells.b.a.d.zh();
                  var13 = new com.aspose.cells.b.a.d.zo(var12);
                  var15 = null;
                  var16 = null;
                  var17 = null;

                  for(var18 = new HashMap(); var20 != null; var20 = var3.f()) {
                     if (var20.startsWith(var5)) {
                        var15 = zamm.a(var20);
                        var18.put(var5, var15);
                     }

                     if (var20.startsWith(var6)) {
                        var16 = zamm.a(var20);
                        var18.put(var6, var16);
                     }

                     if (var20.startsWith(var7)) {
                        var17 = zamm.a(var20);
                        var18.put(var7, var17);
                     }

                     if (var19 > 3) {
                        if (zamm.a(var20, var10)) {
                           var13.c();
                           var12.b(0L);
                           this.a((com.aspose.cells.b.a.d.zm)var12, (HashMap)var18, (String)var16, (Encoding)var2);
                           if ("quoted-printable".equals(var16)) {
                              var13.b();
                           }
                           break;
                        }

                        var13.c(var20);
                     }

                     ++var19;
                  }
               }

               ++var9;
               if (var14) {
                  var13.c();
                  var12.b(0L);
                  this.a((com.aspose.cells.b.a.d.zm)var12, (HashMap)var18, (String)var16, (Encoding)var2);
                  var13.b();
               }
            }
         } catch (Exception var24) {
            ;
         }
      } finally {
         if (var3 != null) {
            var3.a();
         }

      }

      return this.b;
   }

   private void a(com.aspose.cells.b.a.d.zm var1, HashMap var2, String var3, Encoding var4) throws Exception {
      switch(c.a(var3)) {
      case 0:
      case 1:
      case 2:
      case 5:
      default:
         break;
      case 3:
         com.aspose.cells.b.a.d.zm var5 = zavx.a(var1, var4);
         com.aspose.cells.b.a.a.ze.a(this.b, (Object)var2);
         com.aspose.cells.b.a.a.ze.a(this.b, (Object)var5);
         break;
      case 4:
         com.aspose.cells.b.a.a.ze.a(this.b, (Object)var2);
         com.aspose.cells.b.a.a.ze.a(this.b, (Object)var1);
      }

   }
}
